package com.zzy.factory.absfactory.pizzastore.order;


import com.zzy.factory.absfactory.pizzastore.pizza.BJCheesePizza;
import com.zzy.factory.absfactory.pizzastore.pizza.BJGreekPizza;
import com.zzy.factory.absfactory.pizzastore.pizza.BJPepperPizza;
import com.zzy.factory.absfactory.pizzastore.pizza.Pizza;

/**
 * 工厂方法模式，创建对象的方法定义成抽象方法，交给工厂子类去实现
 */
public class OrderBJPizza implements AbsPizzaFactory {
    public Pizza createPizza(String orderType) {
        System.out.println("--------抽象工厂模式--------");

        Pizza pizza = null;
        if ("cheese".equals(orderType)) {
            pizza = new BJCheesePizza();
            pizza.setName("BJ cheese piza");
        } else if ("greek".equals(orderType)) {
            pizza = new BJGreekPizza();
            pizza.setName("BJ greek piza");
        } else if ("pepper".equals(orderType)) {
            pizza = new BJPepperPizza();
            pizza.setName("BJ pepper piza");
        }

        return pizza;
    }

}
